package red.stu.util;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.LinkedList;

import red.stu.mc.api.BlockApi;

public class ClassUtil {
	
	public static String[] getMethods(Class c) {
		LinkedList<String> methodStrs = new LinkedList<>();
		for (Method method : c.getMethods()) {
			int modifiers = method.getModifiers();
			String modifiersStr;
			if (modifiers == 1) {
				modifiersStr = "public void ";
			} else if (modifiers == 9) {
				modifiersStr = "public static void ";
			} else {
				continue;
			}
			
			String methodStr = "";
			for (Parameter parm : method.getParameters()) {
				methodStr += parm.getType().getSimpleName() + " " +parm.getName() + ", ";
			}
			if (methodStr.length() > 2)
				methodStr = methodStr.substring(0, methodStr.length() - 2);
			methodStr = modifiersStr + method.getReturnType().getSimpleName() + " "
					+ method.getName() + "(" + methodStr + ")";
			methodStrs.add(methodStr);
		}
		String[] strs = {};
		strs = methodStrs.toArray(strs);
		return strs;
	}
	
	public static void main(String[] args) {
		String[] strs = ClassUtil.getMethods(BlockApi.class);
		
		for (String s : strs) {
			System.out.println(s);
		}
	}
	
}
